const DB = require('../../../utils/db')
// 引入jwt token工具
const JwtUtil = require('../../../utils/jwt')
/**
 * POST
 * 删除一个帖子
 * 参数：dynamicId帖子id
 */
module.exports = async (ctx) => {
  // 获取token
  let token = ctx.request.header.authorization
  let jwt = new JwtUtil(token)
  // 用token获取到userid
  let userid = jwt.verifyToken()
  // console.log(ctx.request.body)
  let dynamicId = ctx.request.query.dynamicId

    const res = await DB.query(
      `delete from dynamic where userid = '${userid}' and id = '${dynamicId}'`
    )
  console.log(res)
  ctx.body = {
    code: 0,
    data: '已删除',
  }
}
